package com.mingrisoft.database;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.mingrisoft.R;

public class gridadapter extends BaseAdapter {
    private device[] devs;
    private Context context;
    private LayoutInflater inflater;
    public gridadapter(device[] devs, Context context) {
        super();
        this.devs=devs;
        this.context = context;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return devs.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return devs[position];
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        v = inflater.inflate(R.layout.item, null);
        TextView tv=  (TextView) v.findViewById(R.id.descfunc);
        ImageView funcImage=(ImageView)v.findViewById(R.id.imageFunc);
        funcImage.setImageResource(devs[position].getImageID());
        tv.setText(devs[position].getDesc());
        return v;
    }


}
